package com.example.stock;

import org.apache.http.Header;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import com.example.stock.utils.AsyncHttpUtils;
import com.loopj.android.http.RequestParams;
import com.loopj.android.http.TextHttpResponseHandler;

public class MainActivity extends Activity {

	private EditText editText = null;
	private Button button  = null;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		editText = (EditText)findViewById(R.id.input_boxNumber);
		button = (Button)findViewById(R.id.btn_imeClear);
		button.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View arg0) {
				editText.setText("66666111");
			}
		});
		
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}
	
	
	public void httpGet(String url){
		RequestParams params = new RequestParams();
		AsyncHttpUtils.get(url, params,new TextHttpResponseHandler() {
			@Override
			public void onFinish() {
				
			}

			// 开始请求之后，首先走这个start方法，接下来进入onFinish，准备完毕，
			// 能请求到数据的时候进入onSuccess，
			// 当不能请求到数据的时候进入onFailure，这里可能包含了网络错误，链接错误等原因。
			@Override
			public void onStart() {
				super.onStart();
			}

			@Override
			public void onFailure(int arg0, Header[] arg1, String arg2,Throwable arg3) {
				System.out.println(arg3);
				//extView.setText(arg2);
			}

			@Override
			public void onSuccess(int arg0, Header[] arg1, String arg2) {
				System.out.println(arg2);
				//textView.setText(arg2);
			}
		});
		
	}

}
